﻿using CPPEI.ETL.DataServiceInterface;
using CPPEI.WebApi;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using ENT = CPPEI.ETL.Domain.Entities;
using MOD = CPPEI.ETL.Domain.Models;
using SER = CPPEI.ETL.Domain.Services;

namespace CPPEI.ETL.WebApi
{
    [CPPEI.WebApi.AuthPostAction("ETL", "CreateTask", "1.0")]
    public class CreateTaskAction : BaseAction<CreateTaskParams, CreateTaskResult>
    {
        protected override ActionResult<CreateTaskResult> OnExecute(ActionContext context, 
            SysParameters sysParameters,
            CreateTaskParams opParams)
        {
            return new ActionResult<CreateTaskResult>(false, 1, "此接口已经废弃", null);
            /*
            SER.TaskService service = new SER.TaskService();
            ServiceResult result = service.CreateTask(context.UserId,
                opParams.Name,
                opParams.DataServiceId,
                opParams.DataSourceId,
                opParams.RunMode,
                opParams.EnableCodeConversion,
                opParams.EnableDataVerification,
                opParams.CompleteEvent,
                opParams.RunModeSettings,
                opParams.ParameterSettings);
            if(result.IsSuccess)
            {
                return new ActionResult<CreateTaskResult>(new CreateTaskResult());
            }
            else
            {
                return new ActionResult<CreateTaskResult>(result.IsSuccess, result.ErrorCode, result.Message, null);
            }*/
        }
    }

    public class CreateTaskParams
    {
        [Parameter]
        public string Name { get; set; }
        [Parameter]
        public Guid CategoryId { get; set; }

        [Parameter]
        public Guid DataServiceId { get; set; }

        [Parameter]
        public Guid DataSourceId { get; set; }

        [Parameter]
        public int RunMode { get; set; }

        [Parameter]
        public bool EnableCodeConversion { get; set; }

        [Parameter]
        public bool EnableDataVerification { get; set; }

        [Parameter]
        public string CompleteEvent { get; set; }

        /// <summary>
        /// manual:null
        /// timer:begintime,intervalmode,interval
        /// alarm:mode,clock,mode1,clock1,
        /// event:eventName
        /// </summary>
        [Parameter]
        public string RunModeSettings { get; set; }

        /// <summary>
        /// p1,p2,p3
        /// </summary>
        [Parameter]
        public string[] ParameterNames { get; set; }
        /// <summary>
        /// type1,type2,type3
        /// </summary>
        [Parameter]
        public string[] ParameterTypes { get; set; }
        /// <summary>
        /// value1,value2,value3
        /// </summary>
        [Parameter]
        public string[] ParameterValues { get; set; }
        /// <summary>
        /// p1,type,v1,p2,type,v2
        /// </summary>
        [Parameter]
        [Obsolete("不再使用")]
        public string ParameterSettings { get; set; }
    }

    public class CreateTaskResult
    {
    }
}
